<?

/*--------------------------------------------------|
| 是梦的--文档总管[dreamxyp_explorer] 1.05v         |
| 主页：http://code.google.com/p/dreamxyp-explorer/				    |
| Q Q ：31996798				    |
| msn : xiayiping_xyp@hotmail.com  		    |
|---------------------------------------------------|

|---------------------------------------------------|
| Copyright (c) 2003-2004 是梦的[dreamxyp]86cpu.com |
|                                                   |
| 本程式是免费软体                                  |
| 任何人都可以使用，复制，传播，修改                |
|                                                   |
| 请不要删除以上信息！                              |
| 但你在修改完善后，可以请追加上你的信息.           |
|                                                   |
|                             是梦的2004.11.17 北京 |
|--------------------------------------------------*/

//include
//把这个目录改成你所需的目录！
$rootdir= "d:/www/";

//
//下面请不要修改
//
//function
function FolderImg($type)
{
	//图文件路径
	$url= "dtree/img/";

	$type= strtolower($type);
	if (preg_match("(shop)", $type))
	{
		$attachicon= 'shop.gif';
	}
	elseif (preg_match("(webhd)", $type))
	{
		$attachicon= 'webhd.gif';
	}
	elseif (preg_match("(names)", $type))
	{
		$attachicon= 'names.gif';
	}
	elseif (preg_match("(music|movie|tv|rm|ra|rm|rv|wav|mid|mp3|m3u|wma|asf|asx|vqf|mpg|mpeg|avi|wmv)", $type))
	{
		$attachicon= 'musicfolder.gif';
	}
	elseif (preg_match("(img|image|pho|pic|jpg|gif|png|bmp)", $type))
	{
		$attachicon= 'imgfolder.gif';
	}
	elseif (preg_match("(www|http|ftp|htm|web|xml)", $type))
	{
		$attachicon= 'globe.gif';
	}
	else
	{
		$attachicon= 'folder.gif';

	}
	$attachicon= $url . $attachicon;
	return $attachicon;

}

function filetypes($type)
{
	//图文件路径
	$url= "dtree/img/";

	$type= strtolower($type);
	if (preg_match("/(jpg|gif|png|bmp)+$/", $type))
	{
		$attachicon= 'image.gif';
	}
	elseif (preg_match("/(rar)+$/", $type))
	{
		$attachicon= 'rar.gif';
	}
	elseif (preg_match("/(swf|fla|swi)+$/", $type))
	{
		$attachicon= 'flash.gif';
	}
	elseif (preg_match("/(wav|mid|mp3|m3u|wma|asf|asx|vqf|mpg|mpeg|avi|wmv)+$/", $type))
	{
		$attachicon= 'mp.gif';
	}
	elseif (preg_match("/(ra|rm|rv)+$/", $type))
	{
		$attachicon= 'rm.gif';
	}
	elseif (preg_match("/(php|js|pl|cgi|asp|htm|html|css)+$/", $type))
	{
		$attachicon= 'html.gif';
	}
	elseif (preg_match("/(txt|rtf|wri|log|sql)+$/", $type))
	{
		$attachicon= 'page.gif';
	}
	elseif (preg_match("/(chm)+$/", $type))
	{
		$attachicon= 'question.gif';
	}
	elseif (preg_match("/(doc)+$/", $type))
	{
		$attachicon= 'doc.gif';
	}
	elseif (preg_match("/(ppt)+$/", $type))
	{
		$attachicon= 'powerpoint.gif';
	}
	elseif (preg_match("/(zip|arj|arc|cab|lzh|lha|tar|gz)+$/", $type))
	{
		$attachicon= 'zip.gif';
	}
	elseif (preg_match("/(exe|com|bat|dll)+$/", $type))
	{
		$attachicon= 'binary.gif';
	}
	elseif (preg_match("/(torrent)+$/", $type))
	{
		$attachicon= 'torrent.gif';
	}
	else
	{
		$attachicon= 'other.gif';
	}
	$attachicon= $url . $attachicon;
	return $attachicon;
}

function ShowType($type)
{
	//
	$type= strtolower($type);
	if (preg_match("/(jpg|gif|png|bmp)+$/", $type))
	{
		$attachicon= 'img';
	}
	elseif (preg_match("/(swf|fla|swi)+$/", $type))
	{
		$attachicon= 'swf';
	}
	elseif (preg_match("/(wav|mid|mp3|m3u|wma|asf|asx|vqf|mpg|mpeg|avi|wmv)+$/", $type))
	{
		$attachicon= 'mp';
	}
	elseif (preg_match("/(ra|rm|rv)+$/", $type))
	{
		$attachicon= 'rm';
	}
	elseif (preg_match("/(htm|html)+$/", $type))
	{
		$attachicon= 'htm';
	}
	else
	{
		$attachicon= 'down';
	}

	return $attachicon;
}

function EditYN($type)
{
	if (preg_match("/(asp|php|cgi|jsp|css|js|pl|html|htm|txt|log|ini|sql|shtm)+$/", $type))
	{
		return true;
	}
	else
	{
		return false;
	}
}

function getMyPath($mainpath, $relativepath)
{

	$mainpath_info= explode('/', $mainpath);
	$relativepath_info= explode('/', $relativepath);
	$relativepath_info_count= count($relativepath_info);
	for ($i= 0; $i < $relativepath_info_count; $i++)
	{
		if ($relativepath_info[$i] == '.' || $relativepath_info[$i] == '')
			continue;
		if ($relativepath_info[$i] == '..')
		{
			$mainpath_info_count= count($mainpath_info);
			unset ($mainpath_info[$mainpath_info_count -1]);
			continue;
		}
		$mainpath_info[count($mainpath_info)]= $relativepath_info[$i];
	} //end for

	return implode('/', $mainpath_info);
}

function msgyn($msg, $yurl, $nurl= '')
{

	echo "<script language=JavaScript type=text/JavaScript>\n";
	echo "<!--\n";
	echo "var truthBeTold = window.confirm('" . $msg . "');\n";
	echo "if (truthBeTold) { \n";
	echo "document.location.replace('" . $yurl . "');\n";
	echo " }";
	if (!empty ($nurl))
	{
		echo "else{ \n";
		echo "document.location.replace('" . $nurl . "');\n";
		echo " } \n";
	}
	echo "// --></script> \n";

}

function deltree($TagDir)
{ //???????
	if (file_exists($TagDir))
	{
		$mydir= dir($TagDir);
		while ($file= $mydir->read())
		{
			if ((is_dir("$TagDir/$file")) AND ($file != ".") AND ($file != ".."))
			{
				deltree("$TagDir/$file");
			}
			else
			{
				@ unlink("$TagDir/$file");
			}
		}
		$mydir->close();
		rmdir($TagDir);
	}
}

function gowin($link, $top= 'n')
{ //err
	echo "<script language=JavaScript type=text/JavaScript>";
	if ($top == 'y')
	{
		echo "top.document.location.replace('$link');";
	}
	else
	{
		echo "document.location.replace('$link');";
	}
	echo "</script>";
}

///////////////////////////////////////////////////////////////////////////////////////////////////////

function msg($msg)
{

	echo "<script language=JavaScript type=text/JavaScript>";
	echo "window.alert('$msg');";
	echo "</script>";
}
/////////////////////////////////////////////////////////////////////////////////////////////////////

function gore($i= 1)
{

	echo "<script language=JavaScript type=text/JavaScript>";
	echo "history.go(-" . $i . ");";
	echo "</script>";
}

function copyDir($from, $to)
{
	if (!file_exists($from) || !is_dir($from))
	{
		return false;
	}
	if (!file_exists($to) || !is_dir($to))
	{
		mkdir($to, 0777);
		@ chmod($to, 0777);
	}
	$handle= opendir($from);
	while (false !== ($file= readdir($handle)))
	{
		if ($file != "." && $file != "..")
		{
			if (is_dir($from . "/" . $file))
			{
				copyDir($from . "/" . $file, $to . "/" . $file);
			}
			else
				if (is_file($from . "/" . $file))
				{
					copy($from . "/" . $file, $to . "/" . $file);
				}
		}
	}
	return true;
}

function writetofile($filename, $book)
{
	$fd= fopen("$filename", "w");
	fwrite($fd, $book);
	fclose($fd);
}
///  ???????
function conversion_size($size)
{
	if ($size < 1024)
	{
		return substr($size, 0, 5) . 'B';
	}
	else
		if ($size < 1024 * 1024 and $size > 1024)
		{
			$size= $size / 1024;
			return substr($size, 0, 5) . 'K';
		}
		else
			if ($size < 1024 * 1024 * 1024 and $size > 1024 * 1024)
			{
				$size= $size / 1024 / 1024;
				return substr($size, 0, 5) . 'M';
			}
			else
				if ($size < 1024 * 1024 * 1024 * 1024 and $size > 1024 * 1024 * 1024)
				{
					$size= $size / 1024 / 1024 / 1024;
					return substr($size, 0, 5) . 'G';
				}
}

/*--------------------------------------------------|
| 是梦的--文档总管[dreamxyp_explorer] 1.05v         |
| 主页：http://code.google.com/p/dreamxyp-explorer/				    |
| Q Q ：31996798				    |
| msn : xiayiping_xyp@hotmail.com  		    |
|---------------------------------------------------|

|---------------------------------------------------|
| Copyright (c) 2003-2004 是梦的[dreamxyp]86cpu.com |
|                                                   |
| 本程式是免费软体                                  |
| 任何人都可以使用，复制，传播，修改                |
|                                                   |
| 请不要删除以上信息！                              |
| 但你在修改完善后，可以请追加上你的信息.           |
|                                                   |
|                             是梦的2004.11.17 北京 |
|--------------------------------------------------*/
?>